package fulbitofacil.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import fulbitofacil.exception.DAOExcepcion;
import fulbitofacil.negocio.Servicio_adicionalNegocio;

/**
 * Servlet implementation class Servicio_adicionalServlet
 */
@WebServlet("/Servicio_adicionalServlet")
public class Servicio_adicionalServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Servicio_adicionalServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String nombre = request.getParameter("txtNombre");
	    String descripcion = request.getParameter("txtDescripcion");
	    String tarifa = request.getParameter("txtTarifa");
	    int tipo = Integer.parseInt(request.getParameter("txtTipo"));
	    int local = Integer.parseInt(request.getParameter("txtLocal"));
	    
	    
	    
	    
	    
	  //  request.setAttribute("MSG", cadena);    //tipo de memoria donde se pueden guardar atributos
	    
	    
	    Servicio_adicionalNegocio adicional = new Servicio_adicionalNegocio();
	    adicional.insertarServicio_adicional(nombre, descripcion, tarifa, tipo, local);
	    
	    String cadena = "Registrado";
	    request.setAttribute("exito", cadena);
	    	    
	    //PrintWriter out = response.getWriter();
		//out.println("<html><body>"+cadena+"</body></html>");
		
	    RequestDispatcher rd = request.getRequestDispatcher("Servicio_adicional.jsp"); //con esto se separa HTML y JAVA
	    rd.forward(request, response);
		
		
	}

}
